<template>
   <div id="addArticleDetail">
       <el-button @click="backList" type="primary">返回</el-button>
       <box @submit="submit" style="margin-top:1rem"></box>
   </div>
</template>
<script>
    import box from '../components/infoDetail.vue';
    import {createArticle} from 'api/webArticle'
    export default {
        components:{box},
        created(){
               this.$emit('setTitleMsg' , ['官网内容管理','新建文章'])
        },
        methods:{
            submit(params){
                createArticle(params)
                    .then((response)=>{
                        let data= response.data;
                        if(data.resultCode=='200'){
                            let tip='';
                            if(params.status=='DRAFT'){
                                tip='保存成功'
                            }else{
                                tip='发布成功'
                            }
                            this.$alert(tip, '提示', {
                                confirmButtonText: '确定',
                                callback: action => {
                                    this.$router.push({name:'webArticleList'});
                                }
                            })
                        }
                    })
                // console.log(params);
            },
            backList(){
                this.$router.push({name:'webArticleList'});
            }
        }   
    }
</script>
